<?php
	
	require_once 'config.php';
	$ROOT = 'C:\Servidor\Apache2\htdocs\chat_tcc\\';
	require_once("php/Database.php");
	require_once('php/User.php');
	
	$db = new Database;
	$user = new User;
	
	while(true){

		$res = $db->execute('SELECT su.user, su.room, su.last_activity FROM session_update su');

		while($su = mysql_fetch_array($res, MYSQL_ASSOC)){
			$la = $su['last_activity'];
			if (time() > (strtotime($la) + 180)){ //3 * 60 secs				
				$user->setId($su['user']);
				$user->setRoom($su['room']);

				$user->leaveRoom();
			}
		}
	
		sleep(30);
	}

?>